package com.swing.sky.web.generator.util;

import com.swing.sky.web.generator.config.GenConfig;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取配置文件工具
 *
 * @author swing
 */
public class PropertyUtils {
    /**
     * 读取properties文件内容
     */
    public static String readGen(String key) {
        //建立Properties对象
        Properties properties = new Properties();
        //获取文件流
        InputStream inputStream = GenConfig.class.getClassLoader().getResourceAsStream("gen.properties");
        //加载文件流
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty(key);
    }

    /**
     * 读取properties文件内容
     */
    public static String readSky(String key) {
        //建立Properties对象
        Properties properties = new Properties();
        //获取文件流
        InputStream inputStream = GenConfig.class.getClassLoader().getResourceAsStream("orange.properties");
        //加载文件流
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty(key);
    }
}
